package com.qing.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

import com.qing.service.DeptService;
import com.qing.pojo.Dept;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author qinghua
 * @since 2022-06-06
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @PostMapping("/insert")
    public Boolean save(@RequestBody Dept dept) {
        return deptService.saveOrUpdate(dept);
    }

    @GetMapping("/deleteById/{id}")
    public Boolean delete(@PathVariable Integer id) {
        return deptService.removeById(id);
    }

    @PostMapping("/updateById")
    public Boolean updateById(@RequestBody Dept dept) {
        return deptService.updateById(dept);
    }

    @GetMapping("/queryAll")
    public List<Dept> queryAll() {
        return deptService.list();
    }

    @GetMapping("/queryById/{id}")
    public Dept findOne(@PathVariable Integer id) {
        return deptService.getById(id);
    }

}

